package com.bestcem.xm.ticket.enums;

import lombok.Getter;

/**
 * 入口类型枚举
 *
 * @author ympan <yuming.pan@idiaoyan.com>
 * @version v1.0
 * @date 2021/8/31 14:07
 */
@Getter
public enum QuotaQuotaTypeEnum {
    /**
     * normal
     */
    QUOTA_QUOTA_TYPE_NORMAL(0, "QUOTA_QUOTA_TYPE_NORMAL"),

    /**
     * cross
     */
    QUOTA_QUOTA_TYPE_CROSS(1, "QUOTA_QUOTA_TYPE_CROSS");

    private final String name;

    private final Integer index;

    QuotaQuotaTypeEnum(int index, String name) {
        this.name = name;
        this.index = index;
    }

    /**
     * 根据 index 获取枚举实体
     * 找不到则返回 null
     *
     * @param index 枚举索引
     * @return 入口类型枚举
     * @author <yuming.pan@idiaoyan.com>
     * @date 14:15 2021/8/31
     */
    public static QuotaQuotaTypeEnum getByIndex(Integer index) {
        for (QuotaQuotaTypeEnum value : values()) {
            if (value.getIndex().equals(index)) {
                return value;
            }
        }
        return null;
    }
}
